<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>质量验收详情</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/static/css/weadmin.css">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>

<form class="layui-form" action="" lay-filter="formData" >
    <div class="layui-form-item">
        <label class="layui-form-label">项目名称：</label>
        <div class="layui-input-block">
            <input type="text" id="prjName" name="prjName" readonly autocomplete="off"  class="layui-input formData">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">验收类型：</label>
        <div class="layui-input-block">
            <select name="accType" id="accType" class="formData" readonly>
                <option value=""></option>
                <option value="1">地基工程</option>
                <option value="2">防水工程</option>
                <option value="3">钢筋隐蔽工程</option>
                <option value="4">混凝土工程</option>
                <option value="5">屋面工程</option>
                <option value="6">其他</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">建设单位：</label>
        <div class="layui-input-block">
            <input type="text" id="buildCorpName" name="buildCorpName" readonly autocomplete="off"  class="layui-input formData">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">施工单位：</label>
        <div class="layui-input-block">
            <input type="text" id="sgCorpName" name="sgCorpName" readonly autocomplete="off"  class="layui-input formData">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">验收部位：</label>
        <div class="layui-input-block">
            <input type="text" id="prjAreaName" name="prjAreaName" readonly autocomplete="off"  class="layui-input formData">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">验收内容：</label>
        <div class="layui-input-block">
            <input type="text" id="accContent" name="accContent" readonly autocomplete="off"  class="layui-input formData">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">验收人：</label>
        <div class="layui-input-block">
            <textarea type="text" id="accUserName" name="accUserName" readonly autocomplete="off"  class="layui-input formData" rows="8" style="height: 150px;"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">验收时间：</label>
        <div class="layui-input-block">
            <input type="text" id="accTime" name="accTime" readonly autocomplete="off"  class="layui-input formData">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">施工单位检查评定结果：</label>
        <div class="layui-input-block">
            <textarea id="assResult" name="assResult" class="layui-textarea formData" readonly></textarea>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">监理(建设)单位验收结论：</label>
        <div class="layui-input-block">
            <textarea id="accResult" name="accResult" class="layui-textarea formData" readonly></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">现场照片：</label>
        <div class="layui-input-block" id="scenePhotos">

        </div>
    </div>
</form>

<!--<div style="width:794px; margin:0 auto; text-align: right">-->
    <!--<button type="button" class="layui-btn layui-btn-warm" id="accDetailClose">关闭</button>-->
<!--</div>-->









<script type="text/javascript" src="/lib/layui/layui.js"></script>
<script src="/static/js/main.js"></script>
<script>
    layui.use(['jquery', 'configureCom', 'configure', 'sessionFun', 'table'], function () {
        var $ = layui.jquery;
        var configure = layui.configure;
        var table = layui.table;
        var sessionFun = layui.sessionFun;
        var configureCom = layui.configureCom;
        var form = layui.form;
        var token = sessionFun.get(configure.SESSION_TOKEN) ? sessionFun.get(configure.SESSION_TOKEN).token : '';
        var listData = sessionFun.get(configure.SESSION_QLY_ACCEPTANCE_ROW_DATA);//获取 存储的session

        //查详情
        if (listData) {
            //控件赋值
            form.val('formData', listData);
            form.render();
        }else{
            console.log("暂不支持创建质量验收记录");
        }

        //加载验收人
        $.ajax({
            type: "POST",
            url: configure.QLY_ACCEPTANCE_DETAIL_API+'?token='+token,
            data: JSON.stringify({"accId": listData.accId}),
            contentType: "application/json; charset=utf-8",
            success: function (data) {
                var code = data.code;
                var msg = data.msg;
                if (code == "0" || msg == "success") {
                    var list = data.data.personnels;
                    if(list && list.length>0){
                        var personnel1 = "建设单位：\r\n";
                        var personnel5 = "监理单位：\r\n";
                        var personnel9 = "施工单位：\r\n";
                        var personnel10 = "项目单位：\r\n";
                        var personnel99 = "其他\r\n";
                        for(var i=0; i<list.length; i++){
                            var personnel = list[i];
                            if('1'==personnel.orgType){
                                personnel1 = personnel1 + personnel.userName + ' '+ personnel.userRoleName + '\r\n';
                            }else if('5'==personnel.orgType){
                                personnel5 = personnel5 + personnel.userName + ' '+ personnel.userRoleName + '\r\n';
                            }else if('9'==personnel.orgType){
                                personnel9 = personnel9 + personnel.userName + ' '+ personnel.userRoleName + '\r\n';
                            }else if('10'==personnel.orgType){
                                personnel10 = personnel10 + personnel.userName + ' '+ personnel.userRoleName + '\r\n';
                            }else{
                                personnel99 = personnel99 + personnel.userName + ' '+ personnel.userRoleName + '\r\n';
                            }
                        }
                        $("#accUserName").val(personnel1+personnel5+personnel9+personnel10);
                    }
                } else {
                    layer.msg(data.msg);
                }
                layer.closeAll('loading');
            }
        });


        //加载现场照片列表
        $.ajax({
            type: "GET",
            url: configure.QLY_ACCEPTANCE_FILE_LIST_API,
            data: {"token": token, "accId": listData.accId},
            success: function (data) {
                var code = data.code;
                var msg = data.msg;
                if (code == "0" || msg == "success") {
                    var list = data.list;
                    if(list && list.length>0){
                        var queNum = list.length;
                        for(var i=0; i<list.length; i++){
                            var url = '/api/sys/doc/att/'+list[i].id+'?token='+token;
                            var photo = '<img src="'+url+'" />';
                            $("#scenePhotos").append(photo);
                        }
                    }
                } else {
                    layer.msg(data.msg);
                }
                layer.closeAll('loading');
            }
        });

        $(document).on('click','#accDetailClose',function(){
            var currentLay = parent.layer.getFrameIndex(window.name);
            parent.layer.close(currentLay);
        });
    });
</script>
</body>
</html>